from django.shortcuts import render
from django.http import HttpResponse

from . import ana

# Create your views here.

REMOTE_HOST = "https://pyecharts.github.io/assets/js"
def index(request):

    index = '''\

        <h1>XX同学</h1>

        <hr>

        <h2>ChipotleNan 数据分析</h2>

        <h3>

        <a href = '1/'>生成每种商品销售次数的bar图</a><br>
        <a href = '2/'>生成每种商品销售金额的bar图</a><br>

        </h3>

        <hr>

        <h2>电影类的 数据分析</h2>



    '''
    request.session['time']=22
    return HttpResponse('hhh')

    

def index1(request):

    chipo = ana.ChipotleNan()

    bar = chipo.bar_how_many_are_sold_per_item()#生成每种商品销售次数的bar图

    context = dict(
        
        myechart=bar.render_embed(),
        
        host=REMOTE_HOST,
        
        script_list=bar.get_js_dependencies()
        )

    return render(request, 'c2/index.html', context)

def index2(request):

    chipo = ana.ChipotleNan()

    bar = chipo.bar_how_much_are_sold_per_item()#生成每种商品销售金额的bar图

    context = dict(
        
        myechart=bar.render_embed(),
        
        host=REMOTE_HOST,
        
        script_list=bar.get_js_dependencies()
        )

    return render(request, 'c2/index.html', context)
